//author:jxx


//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
  components: {//动态扩充组件或组件路径
    //表单header、content、footer对应位置扩充的组件
    gridHeader: () =>
      import("./account/mall_accountingHeader.vue"),//{ template: "<div>扩展组xx件</div>" },

    gridBody: '',
    gridFooter: '',
    //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
    modelHeader: '',
    modelBody: '',
    modelFooter: ''
  },
  buttons: { view: [], box: [], detail: [] },//扩展的按钮
  methods: {//事件扩展
    onInit () {
      this.maxBtnLength = 4;
      this.boxOptions.height = 530;
      this.columns.push({
        title: '操作',
        fixed: 'right',
        width: 140,
        render: (h, { row, column, index }) => {
          return h(
            "div", { style: {} }, [
            h(
              "a", {
              props: {},
              style: {},
              on: {
                click: (e) => {
                  //this.$Message.info(row.accountsReceivable);
                  // e.stopPropagation()
                  //console.log(this.$refs.gridHeader)
                  this.$refs.gridHeader.open(row);
                }
              }
            },
              "财务处理  "
            ),
            h(
              "a", {
              props: {},
              style: {},
              on: {
                click: (e) => {
                  // 生成的编辑弹框 修改编辑行 列 需要 Vue视图绝对路径 报错（找不到项目路径Vue视图绝对路径）
                  this.linkData(row);
                }
              }
            },
              "编辑"
            ),

          ])
        }
      })
      var effectiveStartDate = this.getFormOption('effectiveStartDate');
      var effectiveEndDate = this.getFormOption('effectiveEndDate');
      effectiveStartDate.onChange = (val, item) => {
        effectiveEndDate.min = val;
      }
      effectiveEndDate.onChange = (val, item) => {
        effectiveStartDate.max = val;
      }

    },




    getFormOption (field) {
      let option;
      this.editFormOptions.forEach(x => {
        x.forEach(item => {
          if (item.field == field) {
            option = item;
          }
        })
      })
      return option;
    },
    rowClick ({ row, column, event }) { //查询界面table点击行选中当前行
      console.log(row, column, event);

      this.$refs.table.$refs.table.toggleRowSelection(row);

      return true;
    },
    modelOpenAfter () {

      //获取当前弹出框是新建还是编辑状态
      let isEDIT = this.currentAction == this.const.EDIT;
      var selectOption = this.getFormOption('accountsReceivable');
      if (!isEDIT) {
        selectOption.onInput = (val) => {
          this.editFormFields.accountsReceivableCode = this.base.chineseToPinYin(val);
        }

        // selectOption.onBlur=(val)=>{
        //     var code = "";
        //     for(var i = 1;i <= 6;i++){         
        //         const num = Math.floor(Math.random()*10);
        //         code += num;
        //     }
        //     this.editFormFields.accountsReceivableCode=this.base.firstZM(this.editFormFields.accountsReceivable)+code
        // }
      }
      var Code = this.getFormOption('accountsReceivableCode');
      this.$set(Code, "disabled", true)
      // var Balance = this.getFormOption('accountBalance');
      // this.$set(Balance, "disabled", !isEDIT)
      var total = this.getFormOption('total');
      this.$set(total, "disabled", !isEDIT)
      var isCredit = this.getFormOption('isCredit');
      isCredit.onChange = (val, item) => {
        //console.log(val) 
        if (val == 1) {
          var creditTotal = this.getFormOption('creditTotal');
          this.$set(creditTotal, "disabled", false)
          this.$set(creditTotal, "required", true)
        } else {
          var creditTotal = this.getFormOption('creditTotal');
          this.$set(creditTotal, "disabled", true)
          this.$set(creditTotal, "required", false)
        }
        //this.getcolumn(val);
        //this.$set(selectOption, "disabled", true);

      }
    }
  }
};
export default extension;